package lcs;

import java.io.Serializable;

public class Classifier implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -7152637054468120985L;
	private State state;
	private int action;
	private double fitness;
	private int accessed = 0;
	
	public Classifier(State state,int action,double fitness)
	{
		this.state = state;
		this.action = action;
		this.fitness = fitness;
	}
	
	public Classifier(State state,int action,double fitness,int accessed)
	{
		this.state = state;
		this.action = action;
		this.fitness = fitness;
		this.accessed = accessed;
	}
	
	public State getState() {
		return state;
	}

	public int getAction() {
		return action;
	}

	public double getFitness() {
		return fitness;
	}

	public void addFitness(double fitness) {
		this.fitness += fitness;
		if( this.fitness <= 0.001 )
			fitness = 0.001;
		++accessed;
	}
	
	public int getAccessed()
	{
		return this.accessed;
	}
	
	@Override
	public boolean equals(Object o)
	{
		if( o instanceof Classifier )
		{
			Classifier c = (Classifier)o;
			return this.state.equals(c.state) 
					&& this.action == c.action
					&& this.fitness == c.fitness
					&& this.accessed == c.accessed;
		}
		return false;
	}
}
